<%@page import="org.hibernate.sql.Update"%>
<%@page import="org.hibernate.event.SaveOrUpdateEvent"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>输入授权密码</title>
	<%@include file="../include/include.jsp"%>
	<link rel="stylesheet" type="text/css" href="${csspath}/public.css"/>
	<link rel="stylesheet" type="text/css" href="${csspath}/datepicker.css"/>
	<link rel="stylesheet" type="text/css" href="${csspath}/style_l.css"/>
	<link rel="stylesheet" type="text/css" href="${csspath}/jquery.alerts.css" />

	<script type="text/javascript" src="${jspath}/jquery-1.4.4.js"></script>
	<script type="text/javascript" src="${jspath}/jquery.ui.min.js"></script>
	<script type="text/javascript" src="${jspath}/ui.datepicker_zh-CN.js"></script>
	<script type="text/javascript" src="${jspath}/jquery.blockUI.js"></script>
	<script type="text/javascript" src="${jspath}/load_layer.js"></script>
	<script type="text/javascript" src="${jspath}/jquery.selectAll.js"></script>
	<script type="text/javascript" src="${jspath}/public.js"></script>
	
	<script type="text/javascript" src="${jspath}/jquery/jquery.ui.draggable.js"></script>
	<script type="text/javascript" src="${jspath}/jquery/jquery.alerts.js"></script>
	
	<script src="${jspath}/jquery/validate/jquery.validationEngine.js" type="text/javascript"></script>
	<script src="${jspath}/jquery/validate/jquery.validationEngine-zh.js" type="text/javascript"></script>
	<link rel="stylesheet" type="text/css" href="${webcontext}/css/validationEngine.jquery.css"/>
	
	<script type="text/javascript">
	$(function(){
		
		$("#sub").click(function(){
			if($("#subForm").validationEngine({returnIsValid:true})){
				$.ajax({
					type:'POST',
					url: '${webcontext}/login/pwdRequired',
					async: false,
					data:$('#subForm').serialize(),
					dataType : 'json',
					success : function(data) {
					   if(data.verifyOperationPwd) {
						   if(data.firstOperationPwd){
						   		window.location.href = '${webcontext}/' + '${url}';
								parent.loadLayer(this, "${webcontext}/login/tofirstUpdateOperationPwd", 751, 152, 250, 600);
						   }else{
						   		window.location.href = '${webcontext}/' + '${url}';
						   }
					   }else{
						   $("#errorPwd").html("密码错误");
					   }
				    }
				});
			}
		});
		
		$("#forget").click(function(){
			jConfirm("确认重置授权密码？","确认提示", function(result){
				if(result == true)
	    		{
					$.ajax({
						type:'POST',
						url: '${webcontext}/ge/dealer/resetpasswd/sendOperationPwd',
						async: false,
						data:"dealerNum="+'${dealerNum}',
						dataType : 'json',
						success : function(data) {
							if(data.exist) {
								jAlert("授权密码重置为"+data.operationPassword+"，已发送到您的手机"+data.contactPhone+"！", "提示信息");
							}else{
								jAlert("账号不可用", "提示信息");
							}
					    }
					});
	    		}
			})
	  });
	});
	</script>
</head>
<form action="${webcontext}/mainpage/loginData" id="toIndex" target="dms_inner"> </form>
<form:form  method="post" modelAttribute="OperationPwdDto" id="subForm">
	<form:hidden path="dealerNum"/>
		<!-- content -->
	<div id="content">
	
		<!-- wrap -->
		<div id="wrap">
			<!-- search_div -->
			<div class="search_div">
				<div class="spliter h_10"></div>
				<table class="search_tab"  align="center" style="width: 420px;">
				<tr>
						<td>&nbsp;</td>
		      	</tr>
				<tr>
				    <td class="label" style="width: 100px;">请输入授权密码：</td>
				    <td><form:password path="operationPassword" cssClass="validate[required] text form-control" id="operationPwd"/></td>
					<td style="width: 100px;"><span id="errorPwd" style="color:red;"></span></td>
		      		<td><div style="width: 100px;"><a href="#" id="forget" style="float:right;"><font color="#CC3399">忘记授权密码</font></a></div></td>
			    </tr>
			      <tr>
						<td>&nbsp;</td>
			      </tr>
					<tr>
						<td colspan="8" class="center2">
							<input type="button" class="btn" id="sub" value="确认"/>
						</td>
					</tr>
					<tr>
						<td>&nbsp;</td>
			      	</tr>
				</table>
				<div class="spliter h_10"></div>
			</div>
			<!-- /search_div -->
			
			<div class="spliter h_10"></div>
			
		</div>
		<!-- /wrap -->
	</div>
	<!-- /content -->
	</form:form>
</body>
</html>